{% extends 'layout/base.twig' %}
{% import 'macros/helpers.twig' as helpers %}

{% block title %}
- 函数详细 - {{ symbol }}
{% endblock %}

{% block content %}
<div class="row-fluid">
    <a class="back-link" href="{{ url('run.view', {'id': id}) }}">&laquo; 返回</a>
    <h1>函数详细</h1>
    <h3 class="function-name">{{ symbol }}</h3>
</div>
<div class="row-fluid">
    <h3>当前函数</h3>
    <table class="table table-hover">
        <thead>
            <tr>
                <th>函数</th>
                <th>调用次数</th>
                <th>自身执行时间</th>
                <th>自身CPU时间</th>
                <th>自身内存占用</th>
                <th>自身内存占用峰值</th>
                <th>包含执行时间</th>
                <th>包含CPU时间</th>
                <th>包含内存占用</th>
                <th>包含内存占用峰值</th>
            </tr>
        </thead>
        <tbody>
        <tr>
            <td class="text">
                {{ helpers.tip_link(
                    current.function,
                    65,
                    'run.symbol',
                    {'id': id, 'symbol': current.function}
                ) }}
                <br>
                Percent of total request
            </td>
            <td>{{ current.ct }}</td>
            <td>{{ current.ewt|as_time }}</td>
            <td>{{ current.ecpu|as_time }}</td>
            <td>{{ current.emu|as_bytes }}</td>
            <td>{{ current.epmu|as_bytes }}</td>

            <td>{{ helpers.time_and_percent('wt', current, main) }}</td>
            <td>{{ helpers.time_and_percent('cpu', current, main) }}</td>
            <td>{{ helpers.bytes_and_percent('mu', current, main) }}</td>
            <td>{{ helpers.bytes_and_percent('pmu', current, main) }}</td>
        </tr>
        </tbody>
    </table>

    <h3>父函数</h3>
    <table class="table table-hover table-sort">
        <thead>
            <tr>
                <th>函数</th>
                <th>调用次数</th>
                <th>自身执行时间</th>
                <th>自身CPU时间</th>
                <th>自身内存占用</th>
                <th>自身内存占用峰值</th>
                <th>包含执行时间</th>
                <th>包含CPU时间</th>
                <th>包含内存占用</th>
                <th>包含内存占用峰值</th>
            </tr>
        </thead>
        <tbody>
        {% for parent in parents %}
        <tr>
            <td class="text">
                {{ helpers.tip_link(
                    parent.function,
                    65,
                    'run.symbol',
                    {'id': id, 'symbol': parent.function}
                ) }}
                <br>
                Percent of total request
            </td>
            <td>{{ parent.ct }}</td>
            <td>{{ parent.ewt|as_time }}</td>
            <td>{{ parent.ecpu|as_time }}</td>
            <td>{{ parent.emu|as_bytes }}</td>
            <td>{{ parent.epmu|as_bytes }}</td>

            <td>{{ helpers.time_and_percent('wt', parent, main) }}</td>
            <td>{{ helpers.time_and_percent('cpu', parent, main) }}</td>
            <td>{{ helpers.bytes_and_percent('mu', parent, main) }}</td>
            <td>{{ helpers.bytes_and_percent('pmu', parent, main) }}</td>
        </tr>
        {% endfor %}
        </tbody>
    </table>

    <h3>子函数</h3>
    <table class="table table-hover table-sort">
        <thead>
            <tr>
                <th>函数</th>
                <th>调用次数</th>

                <th>包含执行时间</th>
                <th>包含CPU时间</th>
                <th>包含内存占用</th>
                <th>包含内存占用峰值</th>
            </tr>
        </thead>
        <tbody>
        {% for child in children %}
        <tr>
            <td class="text">
                {{ helpers.tip_link(
                    child.function,
                    65,
                    'run.symbol',
                    {'id': id, 'symbol': child.function}
                ) }}
            </td>
            <td class="right">{{ child.ct }}</td>

            <td class="right">{{ child.wt|as_time }}</td>
            <td class="right">{{ child.cpu|as_time }}</td>
            <td class="right">{{ child.mu|as_bytes }}</td>
            <td class="right">{{ child.pmu|as_bytes }}</td>
        </tr>
        {% else %}
        <tr>
            <td colspan="6">{{ symbol }} 没有调用函数。</td>
        </tr>
        {% endfor %}
        </tbody>
    </table>

</div>

{% endblock %}
